<?php

namespace Biz\service\wiki;

use Biz\cache\wiki\BrowseHistory as cBrowseHistory;


class WikiBrowseHistory
{

    /**
     * @desc 近七日的wiki浏览记录
     * @param $uid
     * @param $page
     * @return array
     */
    public static function getPagedList($uid, $page)
    {
        //查询wiki浏览记录
        $response = cBrowseHistory::getPagedList($uid, $page, $pageSize = 20);
        $list = isset($response['list']) ? $response['list'] : [];
        $wikiIds = array_keys($list);

        //查询wiki信息
        $wikiInfo = Wiki::getWikiList($wikiIds, $uid);
        $wikiList = [];
        foreach ($list as $wikiId => $v) {
            $item = isset($wikiInfo[$wikiId]) ? $wikiInfo[$wikiId] : [];
            if ($item) {
                $item['addtime'] = $v;
                $wikiList[] = $item;
            }
        }
        $response['list'] = $wikiList;
        return $response;
    }

}
